﻿Public Class MainForm

    Private Sub StageRandomPicture(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonPrevious.Click, ButtonNext.Click, ButtonGood.Click
        ImageStage.Navigate("http://dev.lastask.com/autopic.php?r=" + Rnd().ToString())
    End Sub

    Private Sub main_Resize(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Resize, MyBase.Load
        TabSelector.Left = 0
        TabSelector.Top = 0
        TabSelector.Width = Me.Width
        TabSelector.Height = Me.Height

        ImageStage.Width = TabSelector.SelectedTab.Width - 20
        ImageStage.Height = TabSelector.SelectedTab.Height - TabSelector.SelectedTab.Top - ImageStage.Top - 30

        ButtonSetAsWallpaper.Left = TabSelector.SelectedTab.Width - ButtonSetAsWallpaper.Width - 20
        ButtonGood.Left = ButtonSetAsWallpaper.Left - ButtonGood.Width - 5
    End Sub

    Private Sub ButtonSetWallpaper_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonSetAsWallpaper.Click
        'SystemParametersInfo(SPI_SETDESKTOPWALLPAPER, 0, _WallPaperPath, SPIF_UPDATEINIFILE Or SPIF_SENDWININICHANGE)
    End Sub

    Private Sub MainForm_FormClosing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
        e.Cancel = True
        ActionHideWindow()
    End Sub


    Private Sub NotifyIcon_MouseClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyNotifyIcon.MouseClick
        If e.Button = Windows.Forms.MouseButtons.Left Then
            If Not WindowState = FormWindowState.Maximized Then
                ActionShowWindow()
            Else
                ActionHideWindow()
            End If
        End If
    End Sub

    Private Sub 退出ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 退出ToolStripMenuItem.Click
        MyNotifyIcon.Visible = False
        End
    End Sub

    Private Sub 取消ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 取消ToolStripMenuItem.Click
        NotifyIconContextMenu.Hide()
    End Sub

    Private Sub ActionShowWindow()
        Me.Show()
        WindowState = FormWindowState.Maximized
    End Sub

    Private Sub ActionHideWindow()
        WindowState = FormWindowState.Minimized
        MyNotifyIcon.Visible = True
        Me.Hide()
        'MyNotifyIcon.Text = "text" & vbCr & "text" & vbCr
        MyNotifyIcon.BalloonTipTitle = "WeekAuto 提示信息"
        MyNotifyIcon.BalloonTipText = "已缩小为图标"
        MyNotifyIcon.BalloonTipIcon = ToolTipIcon.Info
        MyNotifyIcon.ShowBalloonTip(10)
    End Sub

    Private Sub ImageStage_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles ImageStage.DocumentCompleted
        'Me.Text = "wolf"
        'SaveSetting("weekauto", "user_configure", "key", "value")
    End Sub

End Class

